<!-- 修改课程考核实施计划 -->
<template>
  <div class="assessment-edit-plan-container">
    <div class="my-form-container" style="margin:0;width: 100%;height:100%">
      <el-form
        :model="tablelist"
        :rules="rules"
        ref="ruleForm"
        class="demo-ruleForm"
      >
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="coursename">
            <div class="my-form-item-label">
              课程名称
            </div>
            <el-input
              v-model="tablelist.coursename"
              style="width:80%"
            ></el-input>
          </el-form-item>
          <el-form-item class="my-form-item" prop="coursenumber">
            <div class="my-form-item-label">课程编号</div>
            <el-input
              v-model="tablelist.coursenumber"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="coursetype">
            <div class="my-form-item-label">
              课程类型
            </div>
            <!-- tablelist.coursetype -->
            <el-select
              v-model="coursetype"
              placeholder="请选择"
              class="bk"
              @input="handleChangePlan"
              clearable
              style="width:80%"
            >
              <el-option
                v-for="(item, index) in kcflList"
                :key="index"
                :label="item.flmc"
                :value="item.flmc"
              >
              </el-option>
            </el-select>
            <el-button
              type="warning"
              plain
              icon="el-icon-setting"
              style=" margin-left:32px;    height: 41px;
                      margin-top: 20px;
                      margin-right: 42px;"
              size="mini"
              @click="kclxwh"
              >课程类型维护</el-button
            >
          </el-form-item>
          <el-form-item class="my-form-item" prop="classhour">
            <div class="my-form-item-label">学 时</div>
            <el-input
              v-model="tablelist.classhour"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="credithour">
            <div class="my-form-item-label">
              学分
            </div>
            <el-input
              v-model="tablelist.credithour"
              style="width:80%"
            ></el-input>
          </el-form-item>
          <el-form-item class="my-form-item" prop="traininglevel">
            <div class="my-form-item-label">
              培养层次
            </div>

            <el-select
              v-model="tlevel"
              placeholder="请选择"
              class="bk"
              @input="handleChangeZY"
              clearable
              style="width:80%"
            >
              <el-option
                v-for="item in syzyList"
                :key="item.value"
                :label="item.dictValue"
                :value="item.dictValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="scoretypecode">
            <div class="my-form-item-label">
              分制
            </div>

            <el-select
              v-model="soreMian"
              placeholder="请选择"
              class="bk"
              @input="handleChangeZY"
              clearable
              style="width:80%"
            >
              <el-option
                v-for="item in scoreList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="my-form-item" prop="oneticketveto">
            <div class="my-form-item-label">课程考核一票否决</div>

            <div class="my-form-item-value">
              <el-radio
                v-model="scoreRadio"
                label="是"
                @change="radioChange"
                :disabled="outlineRadio == '是'"
                >是</el-radio
              >
              <el-radio
                v-model="scoreRadio"
                label="否"
                @change="radioChange"
                :disabled="outlineRadio == '是'"
                >否</el-radio
              >
            </div>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="professionaldivisions">
            <div class="my-form-item-label">
              授课对象
            </div>
            <el-input
              v-model="tablelist.professionaldivisions"
              style="width:80%"
            ></el-input>
          </el-form-item>
          <el-form-item class="my-form-item" prop="totalnumber">
            <div class="my-form-item-label">人 数</div>
            <el-input
              v-model="tablelist.totalnumber"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="openinglaboratory">
            <div class="my-form-item-label">
              开课教研室
            </div>

            <el-select
              v-model="teachingClassName"
              placeholder="请选择"
              class="bk"
              @input="handleChangeZY"
              clearable
              style="width:80%"
            >
              <el-option
                v-for="item in courseTypeList"
                :key="item.value"
                :label="item.value"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="my-form-item" prop="classsize">
            <div class="my-form-item-label">教学班人数</div>
            <el-input
              v-model="tablelist.classsize"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item" prop="coursemanager">
            <div class="my-form-item-label">
              课程负责人
            </div>

            <div class="my-form-item-value">
              <el-autocomplete
                style="width: 92%"
                class="inline-input"
                v-model="courseCharger"
                :fetch-suggestions="querySearch"
                placeholder="请输入内容"
                :trigger-on-focus="false"
                @select="handleSelect"
              ></el-autocomplete>
            </div>
          </el-form-item>
          <el-form-item class="my-form-item" prop="teachingfaculty">
            <div class="my-form-item-label">授课教员</div>
            <el-input
              v-model="tablelist.teachingfaculty"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">课下作业成绩所占比例</div>
            <el-input
              v-model="tablelist.usualscorerate"
              placeholder="请输入"
              type="number"
              style="width:80%"
            ></el-input>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">课堂测试成绩所占比例</div>
            <el-input
              v-model="tablelist.examscorerate"
              placeholder="请输入"
              type="number"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">期中考试成绩所占比例</div>
            <el-input
              v-model="tablelist.midtermscorerate"
              placeholder="请输入"
              type="number"
              style="width:80%"
            ></el-input>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">期末受考成绩所占比例</div>
            <el-input
              v-model="tablelist.experimentscorerate"
              placeholder="请输入"
              type="number"
              style="width:80%"
            ></el-input>
          </el-form-item>
        </div>
        <div style="display:flex">
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">期末考试方式</div>
            <!-- <el-input
              v-model="tablelist.finalexamination"
              placeholder="请输入"
              style="width:80%"
            ></el-input> -->
            <el-select
              v-model="tablelist.finalexamination"
              placeholder="请选择"
              clearable
              @input="handleChangeZY"
            >
              <el-option
                v-for="item in finalexamList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="my-form-item">
            <div class="my-form-item-label">场地需求</div>
            <el-select
              v-model="tablelist.situdemand"
              placeholder="请选择"
              size="small"
              style="width: 187px"
            >
              <el-option
                v-for="(item,index) in classrooms"
                :key="index"
                :label="item.cdmc"
                :value="item.cdmc"
              >
              </el-option>
            </el-select>
            <!-- <el-input
              v-model="tablelist.situdemand"
              placeholder="请输入"
              style="width:80%"
            ></el-input> -->
          </el-form-item>
        </div>

        <div style="display:flex;position: relative;">
          <el-form-item class="my-form-item" style="height: 225px">
            <div class="my-form-item-label">考核设计</div>
            <el-input
              v-model="tablelist.assessmentdesign"
              :rows="8"
              placeholder="请输入"
              class="zyjs"
              type="textarea"
            ></el-input>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <div class="button-group">
      <div @click="addSubmit">保 存</div>
      <div @click="addSubmitU">保存并提交</div>
      <div @click="cancalS">取 消</div>
    </div>
  </div>
</template>

<script>
import { pyccselect } from "@/api/professional/details";
import { reqCourseList } from "@/api/course/courses.js";
import { queryFirstcoursetype } from "@/api/propositionReview/approval";
import { reqCheckCourseTeacher } from "@/api/course/courses.js";
import { update,updateSubmit } from "@/api/courseExame/courseExa";
import { getStore } from '@/util/store.js'
import { getPlaceInfoList} from "@/api/courseAchievement/entryResults";

export default {
  data() {
    return {
      finalexamList: [
        {
          value: "笔试闭卷",
          label: "笔试闭卷"
        },
        {
          value: "笔试开卷",
          label: "笔试开卷"
        },
        {
          value: "口试",
          label: "口试"
        },
        {
          value: "机试",
          label: "机试"
        },
        {
          value: "实操",
          label: "实操"
        },
        {
          value: "课程论文",
          label: "课程论文"
        },
        {
          value: "其他",
          label: "其他"
        }
      ],
      teachingClassName: "",
      tlevel: "",
      coursetype: "",
      soreMian: "",
      courseTypeList: [],
      scoreRadio: "",
      syzy: "",
      kcfl: "",
      showYprDialog: false,
      fileName: "",
      tablelist: {
        mc: "",
        bb: "",
        syzy: "",
        syzyid: "",
        pyfafl: "",
        planFlId: "",
        edzxf: "",
        bxkedxf: "",
        xxkedxf: "",
        zxkedxf: "",
        jzkedxf: "",
        sjjxedxf: "",
        jyxledxf: "",
        fj: "",
        sm: ""
      },
      classrooms: [],
      courseCharger: "",
      // 收集课程负责人数据
      courseChargerList: [],
      scoreList: [
        {
          value: "百分制",
          label: "百分制"
        },
        {
          value: "四分制",
          label: "四分制"
        },
        {
          value: "五分制",
          label: "五分制"
        },
        {
          value: "二分制",
          label: "二分制"
        }
      ],
      syzyList: [],
      kcflList: [],
      finalexamList: [
        {
          value: "笔试闭卷",
          label: "笔试闭卷"
        },
        {
          value: "笔试开卷",
          label: "笔试开卷"
        },
        {
          value: "口试",
          label: "口试"
        },
        {
          value: "机试",
          label: "机试"
        },
        {
          value: "实操",
          label: "实操"
        },
        {
          value: "课程论文",
          label: "课程论文"
        },
        {
          value: "其他",
          label: "其他"
        }
      ],
      roleId:''
    };
  },
  created(){
    const userInfo = getStore({
      name: "userInfo",
      debug: true,
    }) || {}
    this.roleId = userInfo.content.role_id;
  },
  mounted() {
    this.getInit();
    this.pyccselect();
    this.getInitInfo();
    this.getPlaceInfo();
    this.getCourseList();
    // this.getCreateDId(this.tablelist)
  },
  methods: {
    getPlaceInfo(){ 
      getPlaceInfoList(this.cdmc,this.ssjzw,this.zwsTop,this.zwsLow).then(res=>{
        if(res.data.code == 200){
          this.classrooms = res.data.data
        }
      })
    },
    async querySearch(queryString, cb) {
      const result = await reqCheckCourseTeacher(queryString);
      if (result.data.code == 200) {
        this.courseChargerList = result.data.data;
      }
      this.courseChargerList.forEach(item => {
        item.value = item.xm;
      });
      // 调用 callback 返回建议列表的数据
      cb(this.courseChargerList);
    },
    handleSelect(item) {
      this.courseCharger = item.xm;
    },
    kclxwh() {
      //  this.$route.query.index
      this.$router.push({
        path: "/admin/training/classification",
        query: { index: this.index }
      });
    },
    //选择培养方案事件
    handleChangePlan(index) {
      if (index) {
        this.tablelist.planFlId = this.kcflList[index].id;
        this.tablelist.pyfafl = this.kcflList[index].flmc;
      }
    },
    async getInit() {
      const result = await queryFirstcoursetype();
      if (result.data.code == 200 && result.data.data.length > 0) {
        this.kcflList = result.data.data;
      } else {
        this.$message({ type: "error", message: "培养方案分类获取失败！" });
      }
    },
    // 查询教研室
    async getCourseList() {
      const result = await reqCourseList();
      if (result.data.code == 200) {
        this.courseTypeList = result.data.data;
        this.courseTypeList.forEach(item => {
          item.value = item.deptName;
        });
      }
    },
    //培养层次下拉框

    pyccselect() {
      let code = "pylevel";

      return new Promise(() => {
        pyccselect(code).then(res => {
          this.syzyList = res.data.data[0].children;
        });
      });
    },
    //培养分类方案下拉框
    getInitInfo() {
      this.tablelist = this.$route.query.rowIndex;
      this.scoreRadio = this.$route.query.rowIndex.oneticketveto;
      this.coursetype = this.$route.query.rowIndex.coursetype;
      this.soreMian = this.$route.query.rowIndex.scoretypecode;
      this.courseCharger = this.$route.query.rowIndex.coursemanager;
      this.tlevel = this.$route.query.rowIndex.traininglevel;
      this.teachingClassName = this.$route.query.rowIndex.openinglaboratory;
    },

    // 保存
    addSubmit() {
      console.log(this.tablelist)
      let obj = {
        planid:this.$route.query.rowIndex.planid,
        coursename:this.tablelist.coursename,  
        coursenumber: this.tablelist.coursenumber,  
        coursetype: this.coursetype,  
        classhour:this.tablelist.classhour,  
        credithour:this.tablelist.credithour, 
        traininglevel:this.tlevel,
        scoretypecode:this.soreMian,
        oneticketveto:this.scoreRadio,
        professionaldivisions:this.tablelist.professionaldivisions,  
        totalnumber:this.tablelist.totalnumber, 
        openinglaboratory:this.teachingClassName,
        classsize:this.tablelist.classsize,  
        coursemanager:this.courseCharger,
        teachingfaculty:this.tablelist.teachingfaculty,  
        usualscorerate:this.tablelist.usualscorerate,  
        examscorerate:this.tablelist.examscorerate,  
        midtermscorerate:this.tablelist.midtermscorerate,  
        experimentscorerate:this.tablelist.experimentscorerate,
        finalexamination:this.tablelist.finalexamination, 
        situdemand:this.tablelist.situdemand, 
        assessmentdesign:this.tablelist.assessmentdesign, 
      };
      return new Promise(() => {
        update(obj).then(res => {
          if(res.data.code == 200){
              this.$message.success("操作成功!")
               this.$router.push({ path: "/admin/planManagement/Print" });
          }else{
            this.$message.error("操作失败")
            return
          }
        });
      });
   
    },
    //保存并提交
    addSubmitU(){
      this.addSubmit();
      updateSubmit(this.$route.query.rowIndex.planid, this.roleId).then(res => {
        if(res.data.code == 200){
          // this.$message({
          //   type: "success",
          //   message: "操作成功!",
          // });
          this.$router.push("/admin/planManagement/Print");
        } else {
          this.$message.error("提交失败")
          return 
        }
      })
    },
    // 取消
    cancalS() {
      this.$router.push({
        path: "/admin/planManagement/Print" //要跳转的页面的路由
      });
    }
  }
};
</script>
<style lang="less" scoped>
/* /deep/.el-input__inner {
  border: none;
} */
/deep/.el-upload-list {
  position: absolute;
  left: 30%;
  top: 25%;
}
/deep/ .el-form-item__error {
  color: #f56c6c;
  font-size: 12px;
  padding-top: 4px;
  position: absolute;
  top: 75%;
  left: 32%;
}
.mustW {
  color: red;
}
.bk {
  /deep/ .el-input__inner {
    border-radius: 4px;
    // border: 1px solid #004ca7;
  }
}
.zyjs {
  width: 78.8% !important;

  margin: 20px auto;
  /deep/ .el-input__inner {
    height: 50px !important;
    border-radius: 4px;
    border: 1px solid #004ca7;
  }
}
.el-input,
.el-select {
  width: 80%;
  display: flex;
  justify-items: center;
  align-items: center;
  margin-left: 40px;
  margin-right: 40px;
}
/* .el-input:nth-child(-n+2){
  width: 80%;
} */
.el-select:nth-child(-n + 2) {
  width: 80%;
}
.my-form-item {
  width: 100%;
  height: 85px;
  border-bottom: 1px solid rgba(0, 76, 167, 0.39);
  margin-bottom: 0;
  > div {
    display: flex;
    height: 100%;
    &:nth-child(2) {
      .my-form-item-label {
        border-left: 1px solid rgba(0, 76, 167, 0.39);
      }
    }
    .my-form-item-label {
      width: 275px;
      padding-left: 60px;
      background: rgba(0, 76, 167, 0.1);
      display: flex;
      flex: none;
      align-items: center;
      color: #004ca7;
      font-size: 16px;
      font-weight: bold;
      border-left: 1px solid rgba(0, 76, 167, 0.39);
      margin-left: -1px;
      .mustW {
        color: red;
      }
    }
    .el-form-item__content {
      display: flex;
    }
  }
}
.el-date-editor {
  width: 38%;
}
.choose-ypr-container {
  width: 100%;
  margin: 0px auto;

  .choose-ypr-search-container {
    .el-input--prefix .el-input__inner {
      padding-left: 30px;
    }

    .el-input__inner {
      &::placeholder {
        color: #b8b8b8;
      }

      &::-webkit-input-placeholder {
        /* WebKit browsers 适配谷歌 */
        color: #b8b8b8;
      }

      &:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 适配火狐 */
        color: #b8b8b8;
      }

      &::-moz-placeholder {
        /* Mozilla Firefox 19+ 适配火狐 */
        color: #b8b8b8;
      }

      &:-ms-input-placeholder {
        /* Internet Explorer 10+  适配ie*/
        color: #b8b8b8;
      }
    }

    display: flex;
    flex-direction: row;
    align-items: center;

    .title {
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
      margin-right: 5px;
    }

    .search-button {
      width: 77px;
      height: 28px;
      line-height: 28px;
      background: #f1f8fe;
      border: 1px solid #51aef6;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;

      > span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #51aef6;
      }

      > img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }
    }

    .button-list {
      display: flex;
      flex-direction: row;
      align-items: center;
      margin-left: 21px;

      .button-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 69px;
        height: 27px;
        line-height: 27px;
        border: 1px solid #004ca7;
        border-radius: 4px;
        margin-right: 10px;
        text-align: center;
        font-size: 14px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #004ca7;

        .del-icon {
          position: absolute;
          right: 0px;
          top: 0px;
          width: 12px;
          height: 12px;
          padding: 2px;
        }
      }
    }
  }

  .choose-ypr-container .choose-ypr-table-container .el-table__header th {
    padding: 0;
    height: 57px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  /deep/ .el-table .cell {
    color: #004ca7;
  }

  .choose-ypr-table-container {
    margin-top: 30px;

    .el-table td,
    .el-table th.is-leaf,
    .el-table--border,
    .el-table--group {
      border-color: #c7d7eb;
    }

    .el-table__header tr,
    .el-table__header th {
      padding: 0;
      height: 57px;
      background-color: #edf2f9;
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
    }

    .el-table__body tr,
    .el-table__body td {
      padding: 0;
      height: 51px;
    }

    .table-data {
      width: 100%;
      border: 0.8px solid #004ca7;
      border-radius: 9px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #004ca7;
    }
  }
}

.assessment-container {
  .el-dialog__body {
    height: 251px;
  }

  .el-dialog__footer {
    padding: 10px 20px 45px;
  }

  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }

  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
    height: 18px;
    width: 18px;
  }

  .el-checkbox__inner::after {
    height: 10px;
    left: 6px;
  }

  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }

  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }

  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }

  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
}

.cz-save {
  box-sizing: border-box;
  line-height: 44px;
  border-radius: 4px;
  font-size: 12px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  text-align: center;
  margin-top: 70px;
  margin-left: 40px;
  display: flex;
  flex-direction: row;
  cursor: pointer;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.jf-save {
  display: flex;
  align-items: center;
  margin-left: 48px;
}

.fileClass {
  position: relative;
  cursor: pointer;

  .save {
    width: 120px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    color: #fff;
    background: #303133;
  }
}

.my-form-item-value {
  font-size: 16px;
  color: #004ca7;
  height: 100%;
  flex: 1;
  line-height: 60px;
  padding-left: 38px;
  display: flex;
  align-items: center;
}

.assessment-edit-plan-container {
  .assessment-design {
    .el-textarea__inner {
      resize: none;
      font-size: 16px;
      color: rgba(0, 76, 167, 1);
    }
  }
}
</style>
<style scoped lang="less">
.assessment-edit-plan-container {
  .assessment-design {
    padding: 25px 38px !important;
  }

  .button-group {
    cursor: pointer;
    margin-top: 50px;
    text-align: center;

    > div {
      display: inline-block;
      font-size: 18px;
      padding: 6px 22px;
      border-radius: 6px;

      &:nth-child(1) {
        color: #f3b815;
        border: 1px solid #f3b815;
        background: #fff6ef;
        margin-right: 89px;
      }
      &:nth-child(2) {
        color: #02c86c;
        border: 1px solid #02c86c;
        background: #f1fff8;
        margin-right: 89px;
      }
      &:nth-child(3) {
        color: #ff3819;
        border: 1px solid #ff3819;
        background: #ffefef;
      }
    }
  }
}
</style>
